package office.service.finance.impl;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import javax.annotation.Resource;

import office.action.finance.wrapper.PayMoneyWrapper;
import office.action.person.form.TripForm;
import office.bo.person.Trip;
import office.service.finance.IPayMoneyService;
import office.service.person.IPersonService;
import platform.common.exception.BusinessException;
import platform.common.service.impl.BaseBizServiceImpl;

public class PayMoneyServiceImpl extends BaseBizServiceImpl implements IPayMoneyService{

	@Resource
	private IPersonService personalServiceImpl;
	@Override
	public List<PayMoneyWrapper> getAllPayMoney(String state) {
		List<PayMoneyWrapper> payMoneyList = new ArrayList<PayMoneyWrapper>();
		try {
			TripForm tf = new TripForm();
			tf.setState(state);
			List<TripForm> listTripForm = personalServiceImpl.getListTripForFinance(tf);
			for (Iterator<TripForm> iterator = listTripForm.iterator(); iterator.hasNext();) {
				TripForm tripForm = (TripForm) iterator.next();
				PayMoneyWrapper payMoneyWrapper = new PayMoneyWrapper();
				payMoneyWrapper.setId(tripForm.getId());
				payMoneyWrapper.setName("出差费用");
				payMoneyWrapper.setContent(tripForm.getReson());
				payMoneyWrapper.setCreateDate(tripForm.getBeginDate());
				payMoneyWrapper.setMoney(tripForm.getTripMoney());
				payMoneyWrapper.setType("trip");
				payMoneyWrapper.setCreateUser(tripForm.getEntryUserId());
				payMoneyWrapper.setCreateUserCname(tripForm.getEntryUserName());
				payMoneyList.add(payMoneyWrapper);
			}
		} catch (BusinessException e) {
			log.error("", e);
		}
		return payMoneyList;
	}
	
	@Override
	public void doPayMoney(Trip trip) {
		try {
			personalServiceImpl.changeTripStatus(trip);
		} catch (BusinessException e) {
			log.error("", e);
		}
		
	}


}
